<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" import="java.util.*,com.epam.tcs.actions.*,com.epam.tcs.dao.hibernate.entities.*"%>
<%@ include file="../template/header.jsp" %>
<%@ include file="../template/left_menu_alt.jsp" %>
<c:if test="${requestScope.student != null}">
	<c:set var="s" value="${requestScope.student}" />
</c:if>
<div id="content">
	<div id="breadcrumbs">
		<c:if test="${requestScope.breadcrumbs != null}">
			<c:set var="i" value="0"/>
			<c:forEach items="${requestScope.breadcrumbs}" var="bc">
				<a href="${pageContext.request.contextPath}${bc.getUrl()}">${bc.getCaption()}</a>		
			</c:forEach>
		</c:if>
	</div>
	<span style="color: green;">
		${requestScope.message}
	</span>
<form method="post" action="${pageContext.request.contextPath}${requestScope.action}" id="student_form">
	<table>
			<tr>
				<td>Группа</td>
				<td>
				<c:if test="${sessionScope.listGroups != null}" >
					<select name="group">
						<c:forEach items="${sessionScope.listGroups}" var="g">
							<option value="${g.group_id}" ${(s.group.group_id == g.group_id) ? "selected" : ""}>${g.name}</option>						
						</c:forEach>
					</select> 
				</c:if>
				</td>
			</tr>	
			<tr>
				<td>Фамилия</td>
				<td><input type="text" name="lastname" value="${s.lastName}"/></td>
			</tr>
			<tr>
				<td>Имя</td>
				<td><input type="text" name="firstname" value="${s.firstName}"/></td>
			</tr>
			<tr>
				<td>Отчество</td>
				<td><input type="text" name="middlename" value="${s.middleName}"/></td>
			</tr>
			<tr>
				<td>День рождения</td>
				<td><input type="text" name="birthday" id="datepicker" value="${s.birthday}"/></td>
			</tr>
			<tr>
				<td>Почта</td>
				<td><input type="text" name="email" value="${s.email}"/></td>
			</tr>
			<tr>
				<td>Телефон</td>
				<td><input type="text" name="phone" value="${s.phone}"/></td>
			</tr>
			<tr>
				<td>Статус</td>
				<td>
					<select name="status">
						<option value="1">Кандидат</option>
						<option value="2">Учащийся</option>
					</select> 
				</td>
			</tr>
			<tr>
				<td>Комментарии</td>
				<td><textarea name="description">${s.description}</textarea></td>
			</tr>
	</table>
</form>
</div>
<script type="text/javascript">
$(function() {
	$( "#datepicker" ).datepicker($.datepicker.regional['ru']);
	$( ".button" ).button();
	$( "#back_to_student" ).bind('click', function(){
		window.location = "${pageContext.request.contextPath}/tcs/student";
	});	
	$( "#reset_form_student" ).bind('click', function(){
		resetStudentForm($("#student_form"));
	});
	$( "#send_form_student" ).bind('click', function(){
		sendStudentForm();
	});
});

function sendStudentForm(){
	$("#student_form").submit();
}

function resetStudentForm($form) {
    $form.find('input:text, input:password, input:file, select, textarea').val('');
    $form.find('input:radio, input:checkbox')
         .removeAttr('checked').removeAttr('selected');
}
	

</script>
<%@ include file="../template/footer.jsp" %>